<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-store"/>
    <meta http-equiv="Expires" content="0"/>
    <title>智能养老云平台</title>
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/static/favicon.ico}">
    <link rel="stylesheet" th:href="@{/static/plugins/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/static/css/layout.css}">
    <link rel="stylesheet" th:href="@{/static/css/common.css}">
    <link rel="stylesheet" th:href="@{/static/css/main.css}">
    <style>
        .layui-btn-xs {
            height: 18px;
            line-height: 18px;
            padding: 0 3px;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="container">
    <header class="layui-row">
        <div style="width: 1200px;margin-left:auto;margin-right:auto;">
            <div class="logo" onclick="javascript:location.href='/'">
                智能养老云平台
            </div>
            <ul class="layui-nav" style="margin-top:5px;float:right;">
                <li class="layui-nav-item" lay-unselect="">
                    <a href="javascript:;"><img src="/static/imgs/avatar.png" class="layui-nav-img"> <span
                            th:text="${session.user.userName}" style="font-size:18px;"></span></a>
                    <dl class="layui-nav-child">
                        <dd><a id="changepwd" href="javascript:;">修改密码</a></dd>
                        <dd><a href="/logout">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </header>

    <content>
        <div class="center">
            <div class="layui-card ">
                <div class="layui-card-body" style="padding-left:42px;padding-top:42px;overflow: hidden;">
                    <div>
                        <div th:each="m:${session.menus}">
                            <div class="module2 layui-col-lg3 layui-col-sm6 layui-col-xs12 layui-col-md3">
                                <a th:href="${m.uri}">
                                    <div class="m-box">
                                        <img style="width: 160px;height: 160px;" th:src="@{${m.mainLogo}}" alt="">
                                        <p style="text-align: center;width: 150px;margin-top: 15px;margin-bottom:20px;">
                                            <span style="font-size: 18px;" th:text="${m.name}"></span></p>
                                    </div>
                                </a>
                            </div>
                        </div>

                        <div>
                            <div class="module2 layui-col-lg3 layui-col-sm6 layui-col-xs12 layui-col-md3">
                                <!--    <a href="javascript:void(0)" class="jqxd">
                                        <div class="m-box">
                                            <img style="width: 160px;height: 160px;" src="/static/imgs/main-fxyj.png"
                                                 alt="">
                                            <p style="text-align: center;width: 150px;margin-top: 15px;margin-bottom:20px;">
                                                <span style="font-size: 18px;">风险预警</span></p>
                                        </div>
                                    </a>-->
                            </div>
                        </div>
                        <div>
                            <div class="module2 layui-col-lg3 layui-col-sm6 layui-col-xs12 layui-col-md3">
                                <!--   <a href="javascript:void(0)" class="jqxd">
                                       <div class="m-box">
                                           <img style="width: 160px;height: 160px;" src="/static/imgs/main-zyhd.png"
                                                alt="">
                                           <p style="text-align: center;width: 150px;margin-top: 15px;margin-bottom:20px;">
                                               <span style="font-size: 18px;">志愿活动</span></p>
                                       </div>
                                   </a>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="right ">
            <div>
                <div class="layui-card">
                    <div class="layui-card-header">机构信息</div>
                    <div class="layui-card-body jgxx">
                        <p>机构名称：<span th:text="${session.organization.name}"></span></p>
                        <p th:if="${session.organization.nature ne 1}">
                            备案状态：<span th:if="${session.organization.filingStart eq 0}" style="color: red;">未备案</span>
                            <button th:if="${session.organization.filingStart eq 0}" id="filingStart" class="layui-btn layui-btn-normal layui-btn-xs">备案</button>
                            <span th:if="${session.organization.filingStart eq 1}" style="color: orange;">待回执</span>
                            <!--<button th:if="${session.organization.filingStart eq 3}" id="showMsg" class="layui-btn layui-btn-normal layui-btn-xs">查看原因</button>-->
                            <span th:if="${session.organization.filingStart eq 2}" style="color: green;">已上报</span>
                            <span th:if="${session.organization.filingStart eq 3}" style="color: red;">未通过</span>
                            <!--<button th:if="${session.organization.filingStart eq 3}" id="showMsg" class="layui-btn layui-btn-normal layui-btn-xs">查看原因</button>-->
                            <!--<button th:if="${session.organization.filingStart eq 3}" id="shangbao2" class="layui-btn layui-btn-normal layui-btn-xs">再次备案</button>-->
                        </p>
                    </div>
                </div>
            </div>
            <!--<div style="padding-top: 30px;">
                <div class="layui-card">
                    <div class="layui-card-header">通知公告</div>
                    <div class="layui-card-body tzgg">

                        <a href="javascript:void(0)" class="advice " th:each="advice:${adviceList}"
                           th:attr="data-id=${advice.id}"><p th:text="${advice.title}" ></p></a>
                        <a href="javascript:void(0)" class="advice " style="color:#bababa;" th:if="${#lists.isEmpty(adviceList)}">
                            <p th:text="暂无公告" ></p>
                        </a>
                        <div style="text-align: right;font-size: 12px;">
                            <a style="color:darkorange;" href="/advice/ui/list">查看更多 </a>
                        </div>
                    </div>
                </div>
            </div>-->
            <div style="padding-top: 30px;">
                <div class="layui-card">
                    <div class="layui-card-header">技术支持</div>
                    <div class="layui-card-body jszc">
                        <p><img src="/static/imgs/czzn.png" style="width: 20px;padding: 6px;">：<a
                                href="/storage/files/dl/智能养老云平台机构版操作指南.doc"
                                style="color:cornflowerblue;cursor: pointer;">《操作指南》</a></p>
                        <p><img src="/static/imgs/lxdh.png" style="width: 20px;padding: 6px;">：18092382210</p>
                        <p><img src="/static/imgs/qq.png">：2312550337</p>
                    </div>
                </div>
            </div>
        </div>
    </content>
</div>


<input type="hidden" id="cause" th:value="${session.organization.cause}">
<script src="/static/plugins/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['element', 'layer'], function () {
        var $ = layui.$;
        var layer = layui.layer;

        $(".jqxd").on('click', function () {
            layer.alert('功能火速研发中,敬请期待!');
        });
        //修改密码
        $("#changepwd").on('click', function () {
            var id = $(this).data("id");
            var ii = layer.open({
                type: 2,
                content: '/user/changepwd',
                area: ['580px', '295px'],
                btn: ['修改', '取消'],
                title: '修改密码',
                yes: function (layero, index) {
                    var body = layer.getChildFrame('body', layero);
                    var oldpwd = body.find("#oldpwd").val();
                    var newpwd = body.find("#newpwd").val();
                    var rpwd = body.find("#rpwd").val();

                    if (!oldpwd) {
                        layer.msg("请输入原始密码");
                        return;
                    }
                    if (!newpwd) {
                        layer.msg("请输入新密码");
                        return;
                    }
                    if (!rpwd) {
                        layer.msg("请重复新密码");
                        return;
                    }
                    if (newpwd != rpwd) {
                        layer.msg("两次密码输入不一致");
                        return;
                    }
                    if (newpwd === "" || newpwd == null || newpwd.length < 6 || newpwd.length > 16) {
                        layer.msg('密码必须是6-16位');
                        return
                    } else {
                        var pswd = /^[0-9a-zA-Z_$!?]{6,16}$/;
                        if (!pswd.test(newpwd)) {
                            layer.msg("您输入的密码不符合规则，请从新输入");
                            return
                        }
                    }
                    $.ajax({
                        url: "/user/change",
                        data: {oldpwd: oldpwd, newpwd: newpwd},
                        type: 'post',
                        dataType: 'json',
                        success: function (rs) {
                            layer.msg(rs.message);
                            if (rs.code == 200) {
                                layer.close(ii);
                            }
                        }
                    });
                },
                btn2: function (index) {
                    layer.close(index);
                }
            });
        });

        //绑定主机构
        $('#bindPrimary').on('click', function () {
            layer.open({
                type: 2,
                content: '/organization/ui/bindPrimary',
                title: '关联主机构',
                area: ['400px', '250px'],
                btn: ['确定关联', '取消'],
                yes: function (index, layero) {
                    var $primaryName = layer.getChildFrame('#primaryName', index);
                    if ($primaryName.val()) {
                        $.ajax({
                            url: '/organization/bindPrimary',
                            data: {primaryName: $primaryName.val()},
                            type: 'post',
                            dataType: 'json',
                            async: false,
                            success: function (rs) {
                                if (rs.code == 200) {
                                    location.reload();
                                    layer.msg(rs.message);
                                    layer.close(index);
                                } else {
                                    layer.msg(rs.message);
                                }
                            }
                        });
                    } else {
                        layer.msg("请选择所属单位！", {
                            time: 1500
                        });
                    }

                },
                btn2: function (index, layero) {
                    layer.close(index);
                }
            });
        });

        //通知公告
        $("a.advice").on('click', function () {
            var id = $(this).data("id");
            layer.open({
                type: 2,
                content: '/advice/show?id=' + id,
                area: ['800px', '650px'],
                title: '通知详情',
            });
        });

        $("#filingStart").on('click', function () {
            $.get("/judge", function (data) {
                if (data.code === 0) {
                    oo = layer.open({
                        type: 2,
                        content: '/show',
                        area: ['850px', '650px'],
                        title: '备案',
                    });
                }
            });
        });
    });
</script>
</body>
</html>